﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Smalt.MVC.App_Start;
using AutoMapper;
using Smalt.DomainModels.Models;
using Smalt.MVC.Models;
using Smalt.MVC.Mappings.Resolvers;
using System.Collections.Generic;

namespace Smalt.Tests.Mappings
{
    [TestClass]
    public class AutoMapperConfigTest
    {
        [TestMethod]
        public void MappingConfigurationTest()
        {
            // Act
            AutoMapperConfig.Configure();

            // Assert
            Mapper.AssertConfigurationIsValid();
        }

        [TestMethod]
        public void TeamViewResolverTest()
        {
            // Arrange
            Community source = new Community();
            source.Teams = new List<Team>() {
                new Team() { Id = 1, Name = "Team1"},
                new Team() { Id = 2, Name = "Team2"}
            };

            CommunityViewModel destination = new CommunityViewModel();
            AutoMapperConfig.Configure();

            // Act
            Mapper.Map(source, destination);

            // Assert
            Assert.AreEqual("Team1", destination.Teams[1]);
            Assert.AreEqual("Team2", destination.Teams[2]);
        }
    }
}
